<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Deals
 *
 * @author ketu
 */
class Zhishidi_Express_Model_Mysql4_Zone extends Mage_Core_Model_Mysql4_Abstract {

    protected function _construct() {
        $this->_init('zhishidi_express/shipping_zone', 'zone_id');
    }

    protected function _afterSave(Mage_Core_Model_Abstract $object) {
        if ($object->getData('zone_price') && $object->getData('zone_unit')) {

            $condition = $this->_getWriteAdapter()->quoteInto('zone_id = ?', $object->getId());
            $this->_getWriteAdapter()->delete($this->getTable('zhishidi_express/shipping_zone_config'), $condition);

            $this->_getWriteAdapter()->insert($this->getTable('zhishidi_express/shipping_zone_config'), array(
                'zone_price' => $object->getData('zone_price'),
                'zone_unit' => $object->getData('zone_unit'),
                'zone_id' => $object->getData('zone_id'),
            ));
        }

        parent::_afterSave($object);
    }

}

?>
